package com.softer.chengxin.syshome.service.impl;

import com.softer.chengxin.common.domin.Common;
import com.softer.chengxin.syshome.dao.SysHomeDao;
import com.softer.chengxin.syshome.entity.SysModule;
import com.softer.chengxin.syshome.service.SysHomeService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zcz
 * @date 2018/12/26
 */
@Service
public class SysHomeServiceImpl implements SysHomeService {
    @Autowired
    private SysHomeDao homeDao;
    /**
     * @param userName  登陆用户名
     * @param loginType 登陆类型（1:物业企业，0:管理部门）
     * @param projectId 项目ID
     * @return 返回菜单列表
     */
    @Override
    public List<SysModule> selectAll(String userName, String loginType, String projectId) {
        List<SysModule> sysModule = new ArrayList<>();
        if (Common.ONE.equals(loginType)) {
            //数据库中ID为1存的是物业企业菜单
            if (StringUtils.isBlank(projectId)) {
                sysModule = homeDao.selectSysModuleByDicCode(Common.ONE);
            } else {
                sysModule = homeDao.selectSysModuleByDicCode(Common.TWO);
            }
        } else if (Common.ZERO.equals(loginType)) {
            //获取权限id
            sysModule = homeDao.selectSysModuleByLoginName(userName);
        }
        return sysModule;
    }

}
